package com.tcm.doctor.service;

import com.base.core.pager.PageBean;
import com.base.core.pager.PageContext;
import com.base.genid.generator.UidGenerator;
import com.tcm.doctor.domain.dto.DoctorJobtitlePageDto;
import com.tcm.doctor.domain.vo.DoctorJobtitleVo;
import com.tcm.doctor.mapper.DoctorJobtitleMapper;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService;
import org.apache.dubbo.config.annotation.Reference;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@DubboService(version = "0.0.1-alpha",retries = 3, timeout = 6000, delay = -1)
public class DoctorJobtitleServiceImpl implements DoctorJobtitleService {

    @Autowired
    private DoctorJobtitleMapper doctorJobtitleMapper;

    @DubboReference(version = "0.0.1-beta",group = "cached-uid",timeout = 6000, check = false,retries = 3)
    private UidGenerator uidGenerator;

    /**
     * 获取所有数据
     * @return
     */
    @Override
    public List<DoctorJobtitleVo> allJobtitle() {
        List<DoctorJobtitleVo> doctorJobtitleVos = doctorJobtitleMapper.allList();
        return doctorJobtitleVos;
    }

    /**
     * 获取分页数据
     * @param doctorJobtitlePageDto
     * @return
     */
    @Override
    public PageBean<DoctorJobtitleVo> listPage(DoctorJobtitlePageDto doctorJobtitlePageDto) {
        PageContext.setCurrentPage(doctorJobtitlePageDto.getPage());
        PageContext.setPageSize(doctorJobtitlePageDto.getPagesize());
        doctorJobtitlePageDto.setStart(PageContext.getStart());
        List<DoctorJobtitleVo> doctorJobtitleVos = doctorJobtitleMapper.listPage(doctorJobtitlePageDto);
        Long count = doctorJobtitleMapper.count(doctorJobtitlePageDto);
        PageBean<DoctorJobtitleVo> doctorJobtitleVoPageBean = new PageBean<DoctorJobtitleVo>(doctorJobtitleVos, count, doctorJobtitlePageDto.getStart(), doctorJobtitlePageDto.getPagesize());
        return doctorJobtitleVoPageBean;
    }
}
